const webpack = require("webpack");
const nodeExternals = require("webpack-node-externals");
const StartServerPlugin = require("start-server-webpack-plugin");

module.exports = function(options) {
    return {
        ...options,
        entry: ["webpack/hot/poll?100", options.entry],
        watch: true,
        externals: [
            nodeExternals({
                whitelist: ["webpack/hot/poll?100"]
            })
        ],
        plugins: [
            ...options.plugins,
            new webpack.HotModuleReplacementPlugin(),
            new webpack.WatchIgnorePlugin([/\.js$/, /\.d\.ts$/]),
            new StartServerPlugin({ name: options.output.filename })
        ]
    };
};
